using Lzfy_His_Service.Models;

namespace Lzfy_His_Service.Services
{
    /// <summary>
    /// 登录失败限制服务接口
    /// </summary>
    public interface ILoginFailureLimitService
    {
        /// <summary>
        /// 检查用户是否被锁定
        /// </summary>
        /// <param name="userName">用户名</param>
        /// <returns>检查结果</returns>
        Task<LoginFailureCheckResult> CheckUserLockStatusAsync(string userName);

        /// <summary>
        /// 记录登录失败
        /// </summary>
        /// <param name="request">登录失败记录请求</param>
        /// <returns>检查结果（包含是否被锁定）</returns>
        Task<LoginFailureCheckResult> RecordLoginFailureAsync(RecordLoginFailureRequest request);

        /// <summary>
        /// 清除用户的登录失败记录（登录成功时调用）
        /// </summary>
        /// <param name="userName">用户名</param>
        /// <returns>是否成功</returns>
        Task<bool> ClearLoginFailuresAsync(string userName);

        /// <summary>
        /// 手动解锁用户
        /// </summary>
        /// <param name="userName">用户名</param>
        /// <returns>是否成功</returns>
        Task<bool> UnlockUserAsync(string userName);

        /// <summary>
        /// 自动解锁过期的用户
        /// </summary>
        /// <returns>解锁的用户数量</returns>
        Task<int> AutoUnlockExpiredUsersAsync();

        /// <summary>
        /// 获取用户锁定状态详情
        /// </summary>
        /// <param name="userName">用户名</param>
        /// <returns>锁定状态详情</returns>
        Task<UserLockStatus?> GetUserLockStatusAsync(string userName);

        /// <summary>
        /// 获取用户最近的登录失败记录
        /// </summary>
        /// <param name="userName">用户名</param>
        /// <param name="hours">查询最近多少小时的记录（默认24小时）</param>
        /// <returns>登录失败记录列表</returns>
        Task<List<LoginFailureLog>> GetRecentLoginFailuresAsync(string userName, int hours = 24);

        /// <summary>
        /// 清理过期的登录失败记录
        /// </summary>
        /// <param name="daysToKeep">保留多少天的记录（默认30天）</param>
        /// <returns>清理的记录数量</returns>
        Task<int> CleanExpiredLoginFailuresAsync(int daysToKeep = 30);
    }
}